import request from '@/utils/request'

// 查询账单管理列表
export function listBill(query) {
  return request({
    url: '/veterinary/bill/list',
    method: 'get',
    params: query
  })
}

// 查询账单管理详细
export function getBill(billId) {
  return request({
    url: '/veterinary/bill/' + billId,
    method: 'get'
  })
}

// 新增账单管理
export function addBill(data) {
  return request({
    url: '/veterinary/bill',
    method: 'post',
    data: data
  })
}

// 修改账单管理
export function updateBill(data) {
  return request({
    url: '/veterinary/bill',
    method: 'put',
    data: data
  })
}

// 删除账单管理
export function delBill(billId) {
  return request({
    url: '/veterinary/bill/' + billId,
    method: 'delete'
  })
}

// 查询累计未支付账单列表
export function getUnpaidList() {
  return request({
    url: '/veterinary/bill/unpaid',
    method: 'get'
  })
}

// 生成账单编号
export function generateBillNo() {
  return request({
    url: '/veterinary/bill/generateBillNo',
    method: 'get'
  })
}

// 查询账单统计信息
export function getStatistics() {
  return request({
    url: '/veterinary/bill/statistics',
    method: 'get'
  })
}

// 生成客户账单
export function generateCustomerBill(customerId, billPeriodStart, billPeriodEnd) {
  return request({
    url: '/veterinary/bill/generate',
    method: 'post',
    params: {
      customerId: customerId,
      billPeriodStart: billPeriodStart,
      billPeriodEnd: billPeriodEnd
    }
  })
}

// 更新账单支付状态
export function updatePaymentStatus(billId, paidAmount) {
  return request({
    url: '/veterinary/bill/payment',
    method: 'post',
    params: {
      billId: billId,
      paidAmount: paidAmount
    }
  })
}